﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using ThePingMasterConfiguration.Services;
using ThePingMasterConfiguration.ViewModels;

namespace ThePingMasterConfiguration.Commands
{
    public class BrowseFailureCommand : ICommand
    {
        private readonly IOpenFileDialogService _dialogService;
        private readonly ConfigurationModel _configurationModel;

        public BrowseFailureCommand(IOpenFileDialogService dialogService, ConfigurationModel configurationModel)
        {
            _dialogService = dialogService;
            _configurationModel = configurationModel;
        }

        public void Execute(object parameter)
        {
            string filename;
            if (_dialogService.ShowDialog(out filename))
            {
                _configurationModel.OnFailure = filename;
            }
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;
    }
}
